package fr.mairie.parc.page.demande;

import java.util.List;

import javax.annotation.Resource;

import org.apache.click.control.PageLink;
import org.apache.click.dataprovider.DataProvider;
import org.apache.click.util.Bindable;
import org.springframework.context.ApplicationContext;

import fr.mairie.parc.context.AppContext;
import fr.mairie.parc.control.demande.DemandeTable;
import fr.mairie.parc.domain.Demande;
import fr.mairie.parc.page.BorderPage;
import fr.mairie.parc.service.DemandeManager;

public class ListDemandePageOld extends BorderPage {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	@Resource DemandeManager demandeManager ;
	@Bindable protected DemandeTable resultTable = new DemandeTable("resultTable", this, ViewDemandePage.class) ;

	public ListDemandePageOld () {
		resultTable.setDataProvider(new DataProvider<Demande>() {
			private static final long serialVersionUID = 1L;
			public Iterable<Demande> getData() {
				List<Demande> res = demandeManager.selectAll();
		    	return res;
		    }
		});

		PageLink validationRowLink = new PageLink("Validate", EditDemandePage.class);
		validationRowLink.setImageSrc("/assets/images/16x16/application_form_edit.png");
		validationRowLink.setTitle("Edit Validation");
		//validationRowLink.setParameter("referrer", "list-user-dif-request.htm");

		resultTable.addActionColumnLink(validationRowLink);
	}

	@Override
	public void onInit() {
		super.onInit();
		ApplicationContext ctx = AppContext.getApplicationContext();
    	demandeManager = (DemandeManager) ctx.getBean("demandeManager");
	}
}
